package com.fenqing.leetcode.code.t500_600;

import com.fenqing.annotations.Execute;
import com.fenqing.core.Topic;

import java.util.Arrays;

/**
 * @author fenqing
 */
public class Topic561 extends Topic {
    /**
     * 构造器
     *
     * @param input 输入
     */
    public Topic561(String input) {
        super(input);
    }

    @Execute
    public int arrayPairSum(int[] nums) {
        Arrays.sort(nums);
        int sum = 0;
        for(int i = 0; i < nums.length; i += 2){
            sum += nums[i];
        }
        return sum;
    }

    public static void main(String[] args) {
        Topic561 topic = new Topic561("[1,4,3,2]");
        int run = topic.run();
        System.out.println(run);
    }

}
